<?php
/**
 * Created by PhpStorm
 * USER MingTingLiang   QQ 915802070
 * Date 2020-12-16-016   16:34
 */

require "UserEntity.php";
require "UserReg.php";
require "UserInfo.php";
require "UserPhone.php";
require "UserSuccess.php";

//  http://www.monstertrain.com/05duty_reg/reg.php

$tpl = "step1";
session_start();

if (isset($_GET['init'])) {
    unset($_SESSION["user"]);
    echo "情书演示session成功";
}

function getUser()
{
    if (isset($_SESSION['user'])) {
        return json_decode($_SESSION['user']);
    }
    return null;
}

if ($_POST) {
    $userInfo = new UserInfo();
    $userPhone = new UserPhone();
    $userSuccess = new UserSuccess();

    $userInfo->setNextStep($userPhone);
    $userPhone->setNextStep($userSuccess);
    $userInfo->stepNext(getUser());
}
//var_dump(getUser());


$tpl = getUser() == null ? 'step1' : getUser()->step;

?>


<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
<div>
    <form method="post">
        <div>
            <h2>用户注册演示</h2>
        </div>
        <div class="">
           <?php
           include "./tpl/{$tpl}.html";
           ?>
        </div>
    </form>
    <div></div>
</div>

</body>
</html>
